package com.liuyjy2.encryptDecrypt;

import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import org.springframework.stereotype.Component;

/**
 * @Author liuyjy
 * @Date 2025/2/20 13:47
 * @Description: 开关控制逻辑
 **/
@Component
public class CryptoInterceptor extends JacksonAnnotationIntrospector {
    @Override
    public Object findDeserializer(Annotated a) {
        if (a.hasAnnotation(Decrypt.class)) {
            return DynamicCryptoSerializer.class;
        }
        return super.findDeserializer(a);
    }

    @Override
    public Object findSerializer(Annotated a) {
        if (a.hasAnnotation(Encrypt.class)) {
            return DynamicCryptoSerializer.class;
        }
        return super.findSerializer(a);
    }
}

